<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="vue.js"></script> -->
</head>
<body>
    {% extends "views/homeIndex.html" %}
    {% block right %}
    
   <h2 onclick="submitup('myuser')">用户管理</h2>
    <div id="searchUser">
        <div id="searchKuang">
            <form action="/user/searchUser" method="post" id="searchinfo">
                <label>姓名：</label>
                <input type="text" name="username">
                <label>手机号：</label>
                <input type="text" name="phone">
                <label>角色:</label>
                <select name="roleid">
                    <option value="">请选择</option>
                    {% for role in roles %}
                    <option value="{{role.id}}">{{role.rolename}}</option>
                    {% endfor %}
                </select>
                <input type="submit" value="搜索">
                <a href="http://127.0.0.1:3000/creatUser">注册新用户</a>
            </form>
        </div>
        {% if myusers %}
        <table class="hovertable">
            <tr>
                <th>ID</th>
                <th>姓名</th>
                <th>手机</th>
                <th>角色</th>
                <th>操作</th>
            </tr>
            {% for myuser in myusers %}
            <tr>
                <td>{{myuser.id}}</td>
                <td>{{myuser.username}}</td>
                <td>{{myuser.phone}}</td>
                <td>{{myuser.role.rolename}}</td>
                <td>
                    <!-- <a  onclick="submitup('{{myuser.username}}')">修改</a> -->
                    <a href="http://127.0.0.1:3000/updateUser?phone='{{myuser.phone}}'">修改</a>
                    <a onclick="deleteUser('{{myuser.id}}','{{myuser.username}}')">销毁</a>
                </td>
            </tr>
        {% endfor %}
        </table>
        <h2>{{tishi}}</h2>
        {% endif %}
    </div>
    <style type="text/css">
        table {
            width: 750px;
            margin: auto;
            margin-top: 20px;
            font-size:13px;
            color:#333333;
            border-width: 1px;
            border-color: #999999;
            border-collapse: collapse;
        }
        table th {
            /* background-color:black; */
            border-width: 1px;
            padding: 8px;
            border-style: solid;
        }
        /* table tr {
            background-color:#d4e3e5;
        } */
        table td {
            width: 150px;
            border-width: 1px;
            padding: 10px;
            border-style: solid;
        }
        .searchkuang{
            margin-top: 30px;
            padding-top: 20px;
            height: 200px;
        }
        form{
            text-align: center;
        }
        h2{
            text-align: center;
        }
    </style>
    
    <script>
        function Besure(info){
            if(confirm(info)){
                return true;
            }else{
                return false;
            }
        }
        function deleteUser(id,name){
            var text1="确定要销毁用户  ("+name+")  吗？"
            if(Besure(text1)){
                window.location.href="/deleteUserOK?id="+id;
                alert("已销毁用户："+name);
            }
        }
    </script>

    {% endblock %}
    
</body>
</html>